﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_LoginResult : ServerBasePacket
    {
        public const int REASON_LOGIN_OK = 0x00;
        public const int REASON_ACCOUNT_IN_USE = 0x16;
        public const int REASON_ACCOUNT_ALREADY_EXISTS = 0x07;
        public const int REASON_ACCESS_FAILED = 0x08;
        public const int REASON_USER_OR_PASS_WRONG = 0x08;
        public const int REASON_PASS_WRONG = 0x08;

        // public static int REASON_SYSTEM_ERROR = 0x01;

        private byte[] _byte = null;

        public S_LoginResult( int reason )
        {
            buildPacket( reason );
        }

        private void buildPacket( int reason )
        {
            writeC( Opcodes.S_OPCODE_LOGINRESULT );
            writeC( reason );
            writeD( 0x00000000 );
            writeD( 0x00000000 );
            writeD( 0x00000000 );
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = getBytes();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_LoginResult";
        }
    }
}